If we can't load the module using the g_module_build_path() filename, try
authorOwen Taylor <otaylor@redhat.com>
Sun, 3 Mar 2002 03:17:22 +0000 (03:17 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sun, 3 Mar 2002 03:17:22 +0000 (03:17 +0000)
Sat Mar  2 22:11:10 2002  Owen Taylor  <otaylor@redhat.com>

        * gdk-pixbuf-io.c (_gdk_pixbuf_load_module): If we
        can't load the module using the g_module_build_path()
        filename, try loading it as a .la file.

        * test-loaders.c: Look for modules in current directory
        rather than .libs, so we find the right .la files.

        * test-loaders.c: Back out some accidental commits.

gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/test-loaders.c

index 3f11592e860a423d053419e2f0bf4584ecc99f70..1ea423199b0327f74abed03e951898278f04ee5f 100644 (file)
@@ -1,3 +1,14 @@
+Sat Mar  2 22:11:10 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk-pixbuf-io.c (_gdk_pixbuf_load_module): If we
+       can't load the module using the g_module_build_path()
+       filename, try loading it as a .la file.
+
+       * test-loaders.c: Look for modules in current directory
+       rather than .libs, so we find the right .la files.
+
+       * test-loaders.c: Back out some accidental commits.
+
 Sat Mar  2 21:28:03 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk-pixbuf.c (gdk_pixbuf_new): Bullet-proof against integer
@@ -23,7 +34,7 @@ Wed Feb 27 18:33:04 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gdk-pixdata.c (gdk_pixdata_to_csource): Use {} not
        () to group around string assigned to char[]. (#72767,
-       Tomas Ã\96gren)
+       Tomas Ögren)
 
 2002-02-21  Havoc Pennington  <hp@pobox.com>
 
@@ -1245,7 +1256,7 @@ Wed Jun 21 16:02:48 2000  Owen Taylor  <otaylor@redhat.com>
 2000-06-05     Mathieu Lacage  <mathieu@gnome.org>
 
        * configure.in: add some gtk parameters to the
-       GDK_PIXBUF_LIBÃ\82²S and GDK_PIXBUG_INCLUDEDIR vars. One more
+       GDK_PIXBUF_LIBòS and GDK_PIXBUG_INCLUDEDIR vars. One more
        fight in my crusade for strange prefix compile...
 
 2000-05-30  Not Zed  <NotZed@HelixCode.com>
@@ -1342,7 +1353,7 @@ Fri May  5 12:16:32 2000  Owen Taylor  <otaylor@redhat.com>
        * gdk-pixbuf/Makefile.am (INCLUDES): Add $(GNOME_CFLAGS).
        Reported by Jens Finke.
 
-2000-04-14 Tomasz KÃ\82³opczko <kloczek@pld.org.pl>
+2000-04-14 Tomasz Kóopczko <kloczek@pld.org.pl>
 
        * gdk-pixbuf/pixops/makefile.am: $(LIBART_CFLAGS) replaced by 
        $(GTK_CFLAGS) - now gdk-pixbuf compiles correctly.
index 539b2128510251773dee591e1604883f254e4541..13e02f6f0e2456a148188c245f87b29a58ac9a7f 100644 (file)
@@ -279,6 +279,31 @@ get_libdir (void)
 
 #endif
 
+/* Like g_module_path, but use .la as the suffix
+ */
+static gchar*
+module_build_la_path (const gchar *directory,
+                     const gchar *module_name)
+{
+       gchar *filename;
+       gchar *result;
+       
+       if (strncmp (module_name, "lib", 3) == 0)
+               filename = (gchar *)module_name;
+       else
+               filename =  g_strconcat ("lib", module_name, ".la", NULL);
+
+       if (directory && *directory)
+               result = g_build_filename (directory, filename, NULL);
+       else
+               result = g_strdup (filename);
+
+       if (filename != module_name)
+               g_free (filename);
+
+       return result;
+}
+
 /* actually load the image handler - gdk_pixbuf_get_module only get a */
 /* reference to the module to load, it doesn't actually load it       */
 /* perhaps these actions should be combined in one function           */
@@ -307,17 +332,22 @@ _gdk_pixbuf_load_module (GdkPixbufModule *image_module,
          * itself.
          */
         dir = g_getenv ("GDK_PIXBUF_MODULEDIR");
+        if (dir == NULL || *dir == '\0')
+               dir = PIXBUF_LIBDIR;
 
-        if (dir == NULL || *dir == '\0') {
-                
-                path = g_module_build_path (PIXBUF_LIBDIR, module_name);
-                module = g_module_open (path, G_MODULE_BIND_LAZY);
-        } else {
-                path = g_module_build_path (dir, module_name);
-                module = g_module_open (path, G_MODULE_BIND_LAZY);                
-        }        
+       path = g_module_build_path (dir, module_name);
+       module = g_module_open (path, G_MODULE_BIND_LAZY);
 
+       if (!module) {
+               g_free (path);
+               path = module_build_la_path (dir, module_name);
+               module = g_module_open (path, G_MODULE_BIND_LAZY);
+       }
+       
         if (!module) {
+               g_free (path);
+               path = g_module_build_path (dir, module_name);
+               
                 g_set_error (error,
                              GDK_PIXBUF_ERROR,
                              GDK_PIXBUF_ERROR_FAILED,
index a8c9d360bfac835ecdd33f1c0642ceb63593d4ba..3874257966ceb2a0737606d4dd5bf66cd7bd0217 100644 (file)
@@ -62,10 +62,7 @@ record_bytes (gpointer mem, gsize bytes)
 static gpointer
 limited_try_malloc (gsize n_bytes)
 {
-  gpointer mem = malloc (n_bytes + HEADER_SPACE);
-  //fprintf (stderr, "malloced %p\n", mem);
-  
-  return record_bytes (mem, n_bytes);
+  return record_bytes (malloc (n_bytes + HEADER_SPACE), n_bytes);
 }
 
 static gpointer
@@ -81,9 +78,6 @@ limited_calloc (gsize n_blocks,
   int bytes = n_blocks * n_block_bytes + HEADER_SPACE;
   gpointer mem = malloc (bytes);
   memset (mem, 0, bytes);
-
-  //fprintf (stderr, "calloced %p\n", mem);
-  
   return record_bytes (mem, n_blocks * n_block_bytes);
 }
 
@@ -91,14 +85,10 @@ static void
 limited_free (gpointer mem)
 {
   gpointer real = ((char*)mem) - HEADER_SPACE;
-  gint new_allocation;
-  
-  // fprintf (stderr, "Freeing %p\n", real);
 
   g_assert (current_allocation >= 0);
-  new_allocation = current_allocation - GPOINTER_TO_INT (*(void**)real);
-  g_assert (new_allocation >= 0);
-  current_allocation = new_allocation;
+  current_allocation -= GPOINTER_TO_INT (*(void**)real);
+  g_assert (current_allocation >= 0);
   
   free (real);
 }
@@ -386,7 +376,6 @@ main (int argc, char **argv)
   
   putenv ("GDK_PIXBUF_MODULEDIR="BUILT_MODULES_DIR);
 
- #if 0
   TEST (valid_ppm_1, TRUE);
   TEST (valid_ppm_2, TRUE);
   TEST (valid_ppm_3, FALSE); /* image is valid, but we don't handle maxval > 255 */
@@ -414,17 +403,17 @@ main (int argc, char **argv)
 
   TEST (valid_ico_test, TRUE);
   TEST (ico_test_1, FALSE);
-  //  TEST (ico_test_2, FALSE);
+  TEST (ico_test_2, FALSE);
 
   TEST (valid_jpeg_test, TRUE);
   
   TEST (valid_tiff1_test, TRUE);
   TEST (tiff1_test_1, FALSE);
   TEST (tiff1_test_2, FALSE);
-#endif
+#if 0
   TEST (tiff1_test_3, FALSE); /* Segfault in TIFFReadDirectory with libtiff 3.5.5, fixed in 3.5.7 */
+#endif
 
-#if 0
   TEST (valid_tga_test, TRUE);
   TEST (tga_test_1, FALSE);
 
@@ -447,7 +436,7 @@ main (int argc, char **argv)
   TEST_RANDOMLY_MODIFIED (valid_tga_test, FALSE);
   TEST_RANDOMLY_MODIFIED (valid_jpeg_test, FALSE);
   TEST_RANDOMLY_MODIFIED (valid_ico_test, FALSE);
-#endif  
+  
 
   /* memory tests */
 
@@ -466,17 +455,20 @@ main (int argc, char **argv)
        returns successfully, even though they have called the error
        handler with an 'out of memory' message.
   */
+
   max_allocation = PRETEND_MEM_SIZE;
   almost_exhaust_memory ();
 
   g_print ("Allocated %dK of %dK, %dK free during tests\n",
            current_allocation / 1024, max_allocation / 1024,
            (max_allocation - current_allocation) / 1024);
-  LOWMEMTEST (valid_tiff1_test);
-#if 0  
+  
+#if 0
+  LOWMEMTEST (valid_tiff1_test);  
+#endif
   LOWMEMTEST (valid_gif_test);
   LOWMEMTEST (valid_png_test);
   LOWMEMTEST (valid_jpeg_test);
-#endif  
+  
   return 0;
 }